import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALS69gJiQzm3Pj9LDlXi8vHjl0zAASgB\n' +
  'pFSHJRYVd8GlCTdMhj2D/OY4TId8qO+JCIrCZKROUSqzzgFwGgHLZXcCAwEAAQ=='

const privateKey = 'MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAtLr2AmJDObc+P0sO\n' +
  'VeLy8eOXTMABKAGkVIclFhV3waUJN0yGPYP85jhMh3yo74kIisJkpE5RKrPOAXAa\n' +
  'ActldwIDAQABAkBMuh7dDjh6FUhw+H1iixIXDUdbhxw2jtPkKufcw0pvQ9k/GZU2\n' +
  'bty2ilQKZ65ZFslXT2p1KsJL6smpoxbNYFf5AiEA6I+zNALrXs4bCBWPtD3CHuPM\n' +
  'kuccpSsgeu7H8IZDwRsCIQDG8fjqvFRyIyCoPeMfSb/AFx0cGwPM7ojPxTkvOpjO\n' +
  '1QIhAJ/iK1GWsDp9eBgWurUvwEV8VyinuwnSnIHnp420wOABAiBWrdKwI4H/gMKX\n' +
  'yu8MEMvU2705I6QSQ9OkAuAZbcRqSQIhALqkSXIkn4LmIJ5TceiglP7Ibj+tyeTH\n' +
  '05b46fQ5uWsK'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

